<template>
  <div class="purseSubmit">

    <div class="from-box">
      <mt-field label="姓名" placeholder="请输入银行开户姓名" v-model="bank_account"></mt-field>
      <mt-field label="开户行" placeholder="请输入开户行" v-model="bank_name"></mt-field>
      <mt-field label="银行账户" placeholder="请输入银行账户"  type="number" v-model="bank_id"></mt-field>
      <mt-field label="提现金额" placeholder="请输入提现金额" type="number" v-model="amount"></mt-field>

    </div>
    <div class="btn-box">
      <mt-button type="danger" size="large" @click="tixianFn">提现</mt-button>
    </div>
  </div>
</template>

<script>
  import {Toast} from 'mint-ui';
  import { MessageBox } from 'mint-ui';

  export default {
    name: 'Purse',
    data () {
      return {
        bank_account:'',
        bank_name:'',
        bank_id:'',
        amount:0,
      }
    },

    methods: {

      tixianFn:function(){
        var  ajaxData = {};
        ajaxData.customer_id= sessionStorage.user && JSON.parse(sessionStorage.user).customer_id || '';
        ajaxData.bank_id= this.bank_id;
        ajaxData.amount= this.amount;
        ajaxData.bank_name= this.bank_name;
        ajaxData.bank_account= this.bank_account;

        var _this=this;
        $.ajax({
          type:'post',
          url: RouteMap.tixian,
          data:ajaxData,
          success:function(res){
            if(res.code == 200){

//              Toast('提现成功');
              MessageBox({
                title: '提现成功',
                showCancelButton: false,
                confirmButtonText:'返回首页'
              }).then(function(action){
                _this.gotoAddress('/');
              });

            }
            else{
              Toast(res.msg)
            }
          }


        })
      },



      gotoAddress(path){
        this.$router.push(path)
      }

    },

    mounted:function () {
      this.amount = this.$route.query.money || 0;
    }

  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.purseSubmit{
  padding: 0 0.5rem;
  padding-top: 1rem;
}
</style>
